	
//保存资格预审信息(逐条保存，现在已经被取消，"后台ajax逻辑留着")){
	
	//$("textarea[id=textarea"+i+"]").each(function(){
//	var context = $("#textarea"+i+"").val();
//	var pk_prequal = $("#prequal_hidde"+i+"").val();
	//var pk_preSupp = $("#prequal_supp"+i+"").val();
//	$.ajax({
//		url : "<%=request.getContextPath()%>/sourcing/biddingprojlist/suppreply?pk_prequal="+pk_prequal+"&context="+encodeURI(encodeURI(context))+"&randomid="+new Date(),
//		type : "POST",
//		data : "",
//	});
	//});
//}
//资格预审小星星
//	$("#complateBaseInfo input, #complateContactInfo input, #complateBankAccount input, #builddate ,.prequal_textarea")
//     	.not("#supenname, #supsimname, #bizarea, #employeenum,.tel_ext, [name='gender'], [name='position'], #url, #corpFaxReg, #corpFaxNum, #corpFaxExt, .supaccount, .accountname, .bankDocName, [name='prod_filter'], #org_filter")
//     	.UITipInside( {
//      	'required' : true
//     });



//资格预审供应商应答——附件取消事件
function deletePreSuppReply(thisObj){
	$(thisObj).parent('#deletePreSuppReply').remove();
//	$(".imgRemoveName").click(function(){
//		alert(this.value);		
//	});
}	

//资格预审上传附件
function doSuppAffixSave(pk_prequal){

	if (isClientCa == "true") {
		var strSn = getSN(strUserCode);
		if(strSn == null || strSn == ""){
			showMsg(getLanMsg("0ec22211-000058"));
			return;
		}
	}
	
	var url = ebvpContext+"/sourcingcoll/FileUpload_new.jsp";
	//这个uploadMode是什么，type在哪里取。
	url = url + "?" + "uploadMode=1";
	url = url + "&" + "userCode="+strUserCode;
	url = url + "&" + "pkReleaseFileB="+pk_prequal;
	url = url + "&" + "isNeedAddRow=Y";
	var iTop = (window.screen.availHeight-30-330)/2;
	var iLeft = (window.screen.availWidth-10-620)/2;
	window.open(url,'' ,'width=620,height=330,location=no'+',top='+iTop+',left='+iLeft);
	
}


//上传文件
function uploadFile(){
	if(isClientCa == "true"){
		var strSn = getSN(strUserCode);
		if(strSn == null || strSn == ""){
			showMsg(getLanMsg("0ec22210-000030"));
			return;
		}
	}
	var url = ebvpContext+"/sourcingcoll/FileUpload_new.jsp";
	url = url + "?" + "uploadMode=1";
	url = url + "&" + "userCode="+strUserCode;
	url = url + "&" + "isNeedAddRow=Y";
	var iTop = (window.screen.availHeight-30-330)/2;
	var iLeft = (window.screen.availWidth-10-620)/2;
	window.open(url,'' ,'width=620,height=330,location=no'+',top='+iTop+',left='+iLeft);
	return;
}

//后台提交按钮
function doReply(){

	var  finaltime = $("#finaltime").val();
	if(finaltime <= 0){
		disabledForm();
		showMsg(getLanMsg("0ec22210-000031"));
		return;
	}
	if(toAccountSecond <= 0){
		disabledForm();
		showMsg(getLanMsg("0ec22210-000031"));
		return;
	}
	if(!validateRequire()){
		return;
	}

	//有未上传的的附件，给出提示（附件不是必输项）	
	var result = true;
	
	var projNametext = $("#projName").text();
	var projName = "";
	if(projNametext.length > 5){
		projName = projNametext.substring(5,projNametext.length);
	}
	
	var prequal_affix_if = $(".prequal_affix");
	prequal_affix_if.each(function(){
		//获取同级元素，找到id=deletePreSuppReply,的元素，如果有，则代表有附件，如果没有。
		var affix_iflen = $(this).find(".prequal_affix_if").length;  
		var flaglen = $(this).find("#deletePreSuppReply").length;
		var prequalname_title = $(this).parent().find(".prequalname_title").text();
		
		if( affix_iflen >0 && flaglen==0 ){
			//showCfmMsgsch("提示","您还有未上传的附件");
			showCfmMsg("提示", projName+"未按资格预审要求上传附件: " + prequalname_title + "未上传附件 ");
			result = false;
			return;
		}
		
	});
	
	if(result){
		//证书SN
		if(isClientCa == "true"){
			var strSn = getSN(strUserCode);
			if(strSn == null || strSn == ""){
				showMsg(getLanMsg("0ec22210-000030"));
				return;
			}
			document.replyform.casn.value = strSn;
			//方案主键|发布类单据主键|供应商对应用户主键
			var strSignData = pk_release_h + "|" + strUserId;
			//签名
			document.replyform.signature.value = signmessage(strSignData,strUserCode);
		}
		
		document.replyform.action = ebvpContext+"/sourcing/biddingprojlist/invitereply";
		document.replyform.submit();
	}

}

//提交响应信息
var showMsg = function(msg){
	document.getElementById('show_msg').innerHTML = msg;
}

//下载文件
function downloadFile(pk_file,file_name){
	document.replyform.pk_file.value = pk_file;
	document.replyform.file_name.value = file_name;
	document.replyform.action=ebvpContext+"/ebvpfile/download";
	document.replyform.submit();
}
//资格预审下载附件
function downLoadSuppReply(pk_file,file_name){
	document.replyform.pk_file.value = pk_file;
	document.replyform.file_name.value = file_name;
	document.replyform.action=ebvpContext+"/ebvpfile/download";
	document.replyform.submit();
}

//文件验签
function verifyFile(signature,index){
	var fileName = document.getElementsByName("fileName")[index-1].value
	var ret = verfiyFile(fileName,signature,strCert);
	if(ret)
		showMsg(getLanMsg("0ec22210-000032"));
	else
		showMsg(getLanMsg("0ec22210-000033"));
}

var validateRequire = function(){
	var is_agent = document.getElementsByName('is_agent');
	var agent_name = document.getElementById('agent_name');
	if(is_agent[0].checked){
		if(agent_name.value == null || trim(agent_name.value).length == 0){
			showMsg(getLanMsg("0ec22210-000034"));
			agent_name.focus();
			return false;
		}
	}
	var linkman = document.getElementById('agent_person').value;
	var email = document.getElementById('agent_mail').value;
	var phone = document.getElementById('agent_phone').value;
	var tel = document.getElementById('agent_tel').value;
	if(linkman == null || linkman.length == 0){
		showMsg(getLanMsg("0ec22210-000035"));
		document.getElementById('agent_person').focus();
		return false;
	}
	if(email == null || email.length == 0){
		showMsg(getLanMsg("0ec22210-000036"));
		document.getElementById('agent_mail').focus();
		return false;
	}else{
		if(!isEmail(email)){
			showMsg(getLanMsg("0ec22210-000037"));
			document.getElementById('agent_mail').focus();
			return false;
		}
	}
	if(phone != null && phone.length > 0){
		if(!isTelphone(phone) && !isMobel(phone)){
			showMsg(getLanMsg("0ec22210-000038"));
			document.getElementById('agent_phone').focus();
			return false;
		}
	}
	if(tel != null && tel.length > 0){
		if(!isMobel(tel)){
			showMsg(getLanMsg("0ec22210-000039"));
			document.getElementById('agent_tel').focus();
			return false;
		}
	}
	var promise = document.getElementById('promise').value;
	//var reply_note = document.getElementById('textarea21').value;
	if(promise == null || promise.length == 0){
		showMsg(getLanMsg("0ec22210-000040"));
		document.getElementById('promise').focus();
		return false;
	}
	//校验上传文件备注长度
	var objFileNote = document.getElementsByName("reply_file_memo");
	for(var i=0;i<objFileNote.length;i++){
		if(len(objFileNote[i].value) > 50){
			showMsg(getLanMsg("0ec22210-000085") + (i+1) + getLanMsg("0ec22210-000086"));
			objFileNote[i].focus();
			return false;
		}
	}
	//有未给出申请人必备条件的，给出提示，提示必须给填写
	var prequal_condi_if = $(".prequal_textarea");
	prequal_condi_if.each(function(){
		if(this.value == null || this.value.length == 0){ 
			showMsg(getLanMsg("请输入资格预审信息"));
			document.getElementById('prequal_textarea').focus();
			return false;
		}
	});
	return true;
}

var afterReplyHandle = function(){
	if(handleResult != null){
		if(handleResult == "1" || handleResult == "2"){
			disabledForm();
			showMsg(getLanMsg("0ec22210-000041"));
		}
	}
}

var disabledForm = function(){
	//document.getElementByName('textarea').disabled = true;
	$("[name='textarea']").each(function(){
		this.disabled = true;
	});
	$("[class='imgRemoveName']").each(function(){
		this.onclick = "javascript:void(0)";
	});
	document.getElementById('upload').disabled = true;
	document.getElementById('is_join').disabled = true;
	document.getElementById('is_agent').disabled = true;
	document.getElementById('agent_name').disabled = true;
	document.getElementById('agent_person').disabled = true;
	document.getElementById('agent_phone').disabled = true;
	document.getElementById('agent_tel').disabled = true;
	document.getElementById('agent_mail').disabled = true;
	document.getElementById('promise').disabled = true;
	document.getElementById('reply_note').disabled = true;
	document.getElementById('bidSubmit').href = "javascript:void(0)";
	$(".doSuppAffixSavepre").attr("href","javascript:void(0);");
	$(".doSuppAffixSavepre").css("color", "gray");
	document.getElementById('upload').href = "javascript:void(0)";
	var onDeleteBtns = document.getElementsByName('onDelete');
	if(onDeleteBtns != null){
		for(var i=0;i<onDeleteBtns.length;i++){
			onDeleteBtns[i].href = "javascript:void(0)";
		}
		
	}
	
}

function addFileRow(pkReleaseFileB,replyFileName,replyFileSize,replyFilePath){
	
	if(pkReleaseFileB.length>4){
		
		$("#prequal_affix_if"+pkReleaseFileB).attr("value","1");
		var fileName = "";
		//附件长度过长，则截取。span设置了固定的宽度。
		if(replyFileName.length>13){
			fileName = replyFileName.substring(0,13);
		}else{
			fileName = replyFileName;
		}
		$("."+pkReleaseFileB+"").append("<a><span id='deletePreSuppReply' class='deletePreSuppReply' title="+replyFileName+">"+fileName+"<img class='imgRemoveName' onclick='deletePreSuppReply(this);' src='commonres/common/frame/src/img/deleteAffix.png'></img>"
										+"<input type='hidden' id='suppreply_name' name='suppreply_file_name"+pkReleaseFileB+"'  value='"+replyFileName+"' />"
										+"<input type='hidden' id='suppreply_real_path' name='suppreply_file_real_path"+pkReleaseFileB+"'  value='"+replyFilePath+replyFileName+"' />"
										+"<input type='hidden' id='suppreply_size' name='suppreply_file_size"+pkReleaseFileB+"'  value='"+replyFileSize+"' />"
										+"</span></a>");
	}else{
		var strDelBtn = getLanMsg("0ec22210-000012");
		var fileTable = document.getElementById("bidFileTable");
		var rowNo = fileTable.rows.length;
		var row = fileTable.insertRow(rowNo);
		row.id = rowNo;
		if(rowNo%2 == 0){
			row.className = 'odd';
		}
		
		//序号
		var cell = row.insertCell(0);
		cell.align = 'left';
		cell.innerHTML = "<input type='hidden' id='reply_file_real_path' name='reply_file_real_path' value='"+replyFilePath+replyFileName+"' />"+rowNo;
		
		//应答文件名称
		cell = row.insertCell(1);
		cell.align = 'left';
		cell.innerHTML = "<input type='text' id='reply_file_name' name='reply_file_name' class='textfield pd_5x2px' style='text-align:left;width:90%' value='"+replyFileName+"' />"; 
	
		//文件大小
		cell = row.insertCell(2);
		cell.align = 'left';
		cell.innerHTML = "<div>" + roundTwo(replyFileSize/1024) + "KB</div><input type='hidden' id='reply_file_size' name='reply_file_size' value='"+replyFileSize+"' />";
	
		//备注
		cell = row.insertCell(3);
		cell.align = 'left';
		cell.innerHTML = "<input type='text' id='reply_file_memo' name='reply_file_memo' size='50' class='textfield pd_5x2px' style='width:90%'/>";
		
		//删除
		cell = row.insertCell(4);
		cell.align = 'left';
		cell.innerHTML = "<a class='btn_orange' id='onDelete' href='javascript:delFile("+rowNo+");' style='margin-left:3px'><span class='w_34px h_18px ft_14px'>"+strDelBtn+"</span></a>";
	}
}

//删除文件
function delFile(index){
	var bidFileTable = document.getElementById("bidFileTable");
	if (bidFileTable != null) {
		// 获取报价信息有多少行
		var rows = bidFileTable.rows;
		if (rows != null && rows.length > 0) {
			for ( var pos = 0; pos < rows.length; pos++) {
				var row = rows[pos];
				// 寻找要删除的row
				if (row.id == index) {
					bidFileTable.deleteRow(pos);
					break;
				}
			}
		}
	}
}
var roundTwo = function(x) { return Math.round(Math.floor(x * 1000) / 10) / 100; }

var setAgentSupplier = function(){
	var is_agent = document.getElementById('is_agent');
	var agent_name = document.getElementById('agent_name');
	if(is_agent.checked){
		agent_name.disabled = false;
	}else{
		agent_name.value = '';
		agent_name.disabled = true;
	}
}

var afterReplyMsgShow = function(){
	var  finaltime = $("#finaltime").val();
	if(finaltime <= 0){
		disabledForm();
		showMsg(getLanMsg("0ec22210-000031"));
		return;
	}
	if(msg != null && trim(msg).length != 0){
		if(msg == 'success'){
			msg = getLanMsg("0ec22210-000042");
		}else if(msg == 'false'){
			msg = getLanMsg("0ec22210-000031");
		}else{
			msg = getLanMsg("提交失败，请刷新页面再次提交");
		}
		showMsg(msg);
	}
}

//小星星
$(document).ready(function(){
	$("#agent_person,#agent_mail,#promise,.prequal_textarea").UITipInside( {
		'required' : true,
		'cleaner' : false
	});
});